package com.jianzhile.jobs.activities.add;

import android.content.Intent;
import android.graphics.BitmapFactory.Options;
import android.net.Uri;
import android.os.Bundle;

import com.jianzhile.jobs.R;
import com.jianzhile.jobs.base.BaseActivity;
import com.jianzhile.jobs.utils.CommonUtil;
import com.jianzhile.jobs.utils.Const;
import com.jianzhile.jobs.views.photoview.PhotoView;

import java.util.ArrayList;

import butterknife.Bind;
import butterknife.ButterKnife;


/**
 * 查看大图
 */
public class PreviewActivity extends BaseActivity {

	@Bind(R.id.photo_img)
	public PhotoView photo_img;
	
	private Options mDecodingOptions;
	private ArrayList<String> mSelectedList;
	private int mPosition = 0;

	@Override
	public void initView(Bundle savedInstanceState) {
		setContentView(R.layout.activity_preview);
		ButterKnife.bind(this);
		Intent intent = getIntent();
		if (null != intent) {
			mSelectedList = (ArrayList<String>) intent
					.getSerializableExtra(Const.SELECTED_PATH_EXTRA);
			mPosition = intent.getIntExtra(Const.POSITION_EXTRA, 0);
			if (null == mSelectedList || mSelectedList.isEmpty()) {
				this.finish();
			}
		}
		mDecodingOptions = new Options();
		mDecodingOptions.outWidth = CommonUtil.getDisplayWidth(this) / 4;
		
	}

	@Override
	public void setListener() {

	}

	@Override
	public void initData() {
		photo_img.setImageURI(Uri.parse("file://" + mSelectedList.get(mPosition)));
	}

	@Override
	public void onBackPressed() {
		super.onBackPressed();
		overridePendingTransition(0, R.anim.push_top_out);
	}
}